package ai.zixing.factory.simple_factory.controller;

import ai.zixing.factory.simple_factory.entity.AwardInfo;
import ai.zixing.factory.simple_factory.entity.ResponseResult;
import ai.zixing.factory.simple_factory.factory.FreeGoodsFactory;
import ai.zixing.factory.simple_factory.service.IFreeGoods;

public class DeliverController {
    //发放奖品
    public ResponseResult awardToUser(AwardInfo awardInfo){
        try {
            // 根据入参创建具体产品
            IFreeGoods freeGoods = FreeGoodsFactory.getInstance(awardInfo.getAwardTypes());
            ResponseResult responseResult = freeGoods.sendFreeGoods(awardInfo);
            return responseResult;
        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult("201","奖品发放失败!");
        }
    }
}
